/*******************************************************************************
 * Copyright 2011 Alexandre Zglav and Morphiastic
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.morphiastic.analysis.filters;

import java.io.IOException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;

import com.morphiastic.analysis.AnalysisComponentDefinition;


/**
 * The kstem token filter is a high performance filter for english. 
 * All terms must already be lowercased (use lowercase filter) for this filter to work correctly.
 * @author Alex
 *
 */
public class KStemTokenFilter extends ElasticFilter{
	
	public KStemTokenFilter(String defName){
		super(ElasticFilterType.kstem, defName);
	}

	@Override
	public boolean hasCustomParams() {
		return false;
	}

	@Override
	public XContentBuilder addToBuilder(
			XContentBuilder settingsBuilder) throws IOException {
		return settingsBuilder;
	}

	@Override
	public void setParamsFromSettings(Settings tokenizerSettings) {
	}

	@Override
	public boolean areEquivalentDefinitions(AnalysisComponentDefinition other) {
		if(other == null)return false;
		@SuppressWarnings("unused")
		KStemTokenFilter o = null;
		try {
			o = (KStemTokenFilter) other;
		} catch (Exception e) {
			return false;
		}
		return true;
	}
	
}
